#include "DemoContainerCommon.h"
#include "DemoContainer.h"

#include "DemoContainerUnitTestGetSize.h"

DemoContainerSuiteDriverGetSizeTest::DemoContainerSuiteDriverGetSizeTest()
{
  uintTestData_.insert(std::map<int, std::string>::value_type(0, ""));
  uintTestData_.insert(std::map<int, std::string>::value_type(1, "1"));
  uintTestData_.insert(std::map<int, std::string>::value_type(2, "1234567890"));
  uintTestData_.insert(std::map<int, std::string>::value_type(3, "sdfsfsdf\0dsfadsfaf\0"));
  uintTestData_.insert(std::map<int, std::string>::value_type(4, "sdf90546];';,;____"));
}

TEST_F(DemoContainerSuiteStubGetSizeTest, TestGetSize0)
{
  DemoContainer container;
  EXPECT_EQ(ZERO, container.get_size());
}

TEST_F(DemoContainerSuiteDriverGetSizeTest, TestGetSizeMore)
{
  DemoContainer container;
  std::map<int, std::string> tmpData = this->get_usedata();

  for ( std::map<int, std::string>::iterator iter = tmpData.begin();
    iter != tmpData.end(); iter++ )
  {
    container.add_item( iter->second );
  }

  EXPECT_EQ(tmpData.size(), container.get_size());
}


TEST_F(DemoContainerSuiteDriverGetSizeTest, TestGetSizeAllSameData)
{
  DemoContainer container;
  std::map<int, std::string> tmpData = this->get_usedata();

  std::map<int, std::string>::iterator iter = tmpData.begin();

  if ( iter != tmpData.end() )
  {
    for ( int i = 0; i < 10; i++ )
    {
      container.add_item( iter->second );
    }

    EXPECT_EQ(ONE, container.get_size());
  }
}

TEST_F(DemoContainerSuiteDriverGetSizeTest, TestGetSizeTwoNoSameData)
{
  DemoContainer container;
  std::map<int, std::string> tmpData = this->get_usedata();

  for ( int i = 0; i < 10; i++ )
  {
    container.add_item( tmpData[ZERO] );
  }

  EXPECT_EQ(ONE, container.get_size());

  for ( int i = 0; i < 10; i++ )
  {
    container.add_item( tmpData[ONE] );
  }

  EXPECT_EQ(TWO, container.get_size());
}

TEST_F(DemoContainerSuiteDriverGetSizeTest, TestGetSizeFiveNoSameData)
{
  DemoContainer container;
  std::map<int, std::string> tmpData = this->get_usedata();

  for ( int i = 0; i < 10; i++ )
  {
    container.add_item( tmpData[ZERO] );
  }

  EXPECT_EQ(ONE, container.get_size());

  for ( int i = 0; i < 10; i++ )
  {
    container.add_item( tmpData[ONE] );
  }

  EXPECT_EQ(TWO, container.get_size());

  for ( int i = 0; i < 10; i++ )
  {
    container.add_item( tmpData[TWO] );
  }

  EXPECT_EQ(THREE, container.get_size());

  for ( int i = 0; i < 10; i++ )
  {
    container.add_item( tmpData[THREE] );
  }

  EXPECT_EQ(FOUR, container.get_size());

  for ( int i = 0; i < 10; i++ )
  {
    container.add_item( tmpData[FOUR] );
  }

  EXPECT_EQ(FIVE, container.get_size());

}
